﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Xml.Serialization;

namespace Inbox.Domain
{
    [Table(Name = "dbo.InboxRole")]
    public class InboxRole : PersistentObject
    {
        [Column(Name = "[Level]", Storage = "Level", DbType = "Int", UpdateCheck = UpdateCheck.Never)]
        public int? Level { get; set; }

        [Column(Storage = "Company", DbType = "NVarChar(50)", UpdateCheck = UpdateCheck.Never)]
        public string Company { get; set; }

        [Column(Storage = "Department", DbType = "NVarChar(50)", UpdateCheck = UpdateCheck.Never)]
        public string Department { get; set; }

        [global::System.Data.Linq.Mapping.ColumnAttribute(Storage = "UserID", DbType = "UniqueIdentifier", UpdateCheck = UpdateCheck.Never)]
        public Guid? UserID { get; set; }

        private EntityRef<InboxUser> _InboxUserRef;
        [Association(Name = "InBoxUser_InboxRole", Storage = "InboxUser", ThisKey = "UserID", OtherKey = "ID", IsForeignKey = true)]
        public InboxUser InboxUser
        {
            get
            {
                return this._InboxUserRef.Entity;
            }
            set
            {
                if (value != null)
                    this.UserID = value.ID;
                else
                    this.UserID = Guid.Empty;
            }
        }

        public InboxRole()
        {
            this._InboxUserRef = new EntityRef<InboxUser>();
        }
    }
}
